package rolesystem.agentlogic.utilityclasses;

import java.io.Serializable;

import rolesystem.agentlogic.managers.EnvironmentManager;

public class PositionSq implements Serializable
{
	public int pos_x;
	public int pos_y;
	
	public PositionSq()
	{
	}
	
	public PositionSq(int pos_x,int pos_y)
	{
		this.pos_x=pos_x;
		this.pos_y=pos_y;
	}
	
	public PositionSq(PositionSq pos)
	{
		this.pos_x=pos.pos_x;
		this.pos_y=pos.pos_y;
	}
	
	public boolean checkBounds()
	{
		if( pos_x >= EnvironmentManager.ENV_MAX_X || pos_y >= EnvironmentManager.ENV_MAX_Y || pos_x < 0 || pos_y < 0)
			return true;
		else
			return false;
	}
	
	public void checkAndCorrectBounds()
	{
		if(pos_x<0)
			pos_x=0;
		
		if(pos_y<0)
			pos_y=0;
		
		if(pos_x>=EnvironmentManager.ENV_MAX_X)
			pos_x=EnvironmentManager.ENV_MAX_X-1;
		
		if(pos_y>=EnvironmentManager.ENV_MAX_Y)
			pos_y=EnvironmentManager.ENV_MAX_Y-1;
	}

}
